package cn.pzhu.controller.web;

import cn.pzhu.controller.BaseController;
import cn.pzhu.model.Achievement;
import cn.pzhu.model.Category;
import cn.pzhu.model.Demand;
import cn.pzhu.services.web.WebAcheievementServices;
import cn.pzhu.services.web.WebCategoryServices;
import cn.pzhu.services.web.WebDemandServices;

import java.util.List;

/**
 * Created by dongp on 2016/5/8.
 */
public class WebDemandController extends BaseController {

    private WebCategoryServices categoryServices = new WebCategoryServices();
    private WebDemandServices webDemandServices = new WebDemandServices();

    public void queryPage(){
        // 获取查询条件参数
        String typeVal = getPara("typeVal","");
        String search = getPara("search","");

        List<Category> categoryList = categoryServices.queryList();
        setAttr("categoryList", categoryList);

        List<Demand> demandList = webDemandServices.queryPage(getRequest(),typeVal,search);
        setAttr("demandList",demandList);
        render("demand/demand.jsp");
    }

    public void queryById() {
        int id = getParaToInt("id");
        Demand demand = webDemandServices.queryById(id);
        setAttr("demand",demand);
        render("demand/demandDetail.jsp");
    }
}
